﻿using WenAntdUI.Models;

namespace WenAntdUI.Pages.SysAdmin
{
    [Description("菜单管理")]
    public partial class SysMenuPage : UserControl
    {
        IFreeSql fsql;
        public SysMenuPage(IFreeSql fsql)
        {
            this.fsql = fsql;
            InitializeComponent();

            this.adminTable1.Table.Gap = 12;
            this.adminTable1.Table.RowHeight = 40;

            this.adminTable1.SetColumn<SysMenuDto>()
                .Add(a => a.Name, 288, c => c.SetTree(nameof(SysMenuDto.Childs)))
                .Add(a => a.Code)
                .Add(a => a.ParentCode)
                .Add(a => a.OrderNo)
                .Add(a => a.IconImage)
                .Add(a => a.MenuType)
                .Add(a => a.Description)
                .Add(a => a.ControlType);

            this.adminTable1.QueryData = async e =>
            {
                e.IsExpand = true;
                return fsql.Select<SysMenuDto>()
                .WhereIf(!string.IsNullOrWhiteSpace(e.QueryText), a => a.Name.Contains(e.QueryText))
                .ToTreeList();
            };
            this.adminTable1.Query();
        }
    }
}
